home *** CD-ROM | disk | FTP | other *** search
/ How Computers Work (Alt) / HowComputersWork.iso / Walkthrough / Mill / HCW.DXR / 00623_BH - Button BehaviorNAV w-RolloverDUPLICATE.ls < prev    next >
Encoding:
Text File  |  1999-07-26  |  2.6 KB  |  82 lines

  1. property pState, pSprite, pButtonRl, pButtonUp, pButtonDn, pSNDdn, pSNDup, pDestination, pMyButton
  2. global gMarkerList
  3.  
  4. on beginSprite me
  5.   set pSprite to the currentSpriteNum
  6.   resetMyButton()
  7.   set pState to #off
  8. end
  9.  
  10. on mouseDown me
  11.   set the member of sprite pSprite to pButtonDn
  12.   set pMyButton to pSprite
  13.   puppetSound(4, pSNDdn)
  14.   updateStage()
  15. end
  16.  
  17. on mouseUp me
  18.   if pMyButton = pSprite then
  19.     set the member of sprite pSprite to pButtonRl
  20.     puppetSound(4, pSNDup)
  21.     set pState to #on
  22.     updateStage()
  23.     if pDestination = "*VOID*" then
  24.     else
  25.       puppetSound(2, 0)
  26.       go(pDestination)
  27.     end if
  28.   end if
  29.   sendAllSprites(#resetMyButton)
  30. end
  31.  
  32. on mouseUpOutSide me
  33.   set the member of sprite pSprite to pButtonUp
  34.   set pState to #off
  35.   updateStage()
  36.   sendAllSprites(#resetMyButton)
  37. end
  38.  
  39. on mouseEnter me
  40.   set the member of sprite pSprite to pButtonRl
  41.   if the stillDown = 1 then
  42.     if pMyButton = pSprite then
  43.       set the member of sprite pSprite to pButtonDn
  44.     end if
  45.   end if
  46.   updateStage()
  47. end
  48.  
  49. on mouseLeave me
  50.   set the member of sprite pSprite to pButtonUp
  51.   updateStage()
  52. end
  53.  
  54. on resetMyButton
  55.   set pMyButton to 0
  56. end
  57.  
  58. on getPropertyDescriptionList me
  59.   set gMarkerList to []
  60.   repeat with x = 1 to the number of lines in the labelList
  61.     set litem to line x of the labelList
  62.     if litem <> EMPTY then
  63.       add(gMarkerList, litem)
  64.     end if
  65.   end repeat
  66.   set lup to the name of member the memberNum of sprite the currentSpriteNum
  67.   set lrl to char 1 to the number of chars in lup - 2 of lup & "rl"
  68.   set ldn to char 1 to the number of chars in lup - 2 of lup & "dn"
  69.   set description to [:]
  70.   addProp(description, #pButtonRl, [#default: lrl, #format: #bitmap, #comment: "Button Roll:"])
  71.   addProp(description, #pButtonUp, [#default: lup, #format: #bitmap, #comment: "Button Up:"])
  72.   addProp(description, #pButtonDn, [#default: ldn, #format: #bitmap, #comment: "Button Down:"])
  73.   addProp(description, #pSNDdn, [#default: "S - MouseDown", #format: #sound, #comment: "Down Sound:"])
  74.   addProp(description, #pSNDup, [#default: "S - MouseUp", #format: #sound, #comment: "Up Sound:"])
  75.   addProp(description, #pDestination, [#default: "*VOID*", #format: #string, #comment: "Go To Marker:", #range: gMarkerList])
  76.   return description
  77. end
  78.  
  79. on getBehaviorDescription me
  80.   return "This behavior allows for a button with an up, down, and rollover state." & RETURN & "Drag and drop this on any button, then select the up, down and rollover states of the button, as well as the sounds the button is to make when clicked and the destination the button is to send the user to." & RETURN & "You can call on the pState of sprite X to find out if the button is on or off."
  81. end
  82.